<%@page import="java.util.Locale"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<link href="css/common.css" rel="stylesheet" type="text/css"/>

<div class="banner-top clearfix">
    <ul class="pull-left">
        <li><%=new SimpleDateFormat("yyyy/MM/dd EEEE",Locale.CHINA).format(new Date()) %> </li>
    </ul>
    <c:if test="${empty comp}">
    	<ul class="pull-right ">
	        <li class="btn1"><span class="icon-sign"></span>登录<span class="line"></span></li>
	        <li><a href="register.jsp" target="_blank">注册</a></li>
    	</ul>
    </c:if>
    
    <c:if test="${not empty comp}">
    	<div class="pull-right signed">
        <h3><span class="icon-sign"></span>${comp.comp_name }</h3>
        <i class="arrowed"></i>
        <ul class="clearfix">
            <li class="one"><a href="personlCenter.jsp">个人中心</a></li>
            <li><a href="company_logout">退出</a></li>
        </ul>
    </c:if> 
</div>  
</div>

<!-- banner -->
<div class="banner">
    <img src="images/banner.png">
    <div class="logo">
        <img src="./images/logo.png" alt="协会Logo"/>
    </div>
</div>

<!--导航-->
<div class="warp" id="warps">
    <ul class="center" id="menuId">
    </ul>
</div>

<div class="covers"></div>
<div id="sigin" class="modal">
    <h3>用户登录<i></i></h3>
    <form id="loginForm"  action="company_login" class="layui-form" method="post">
    <table>
            <tbody><tr>
                <td>用户名：</td>
                <td><input id="usernames" type="text" placeholder="输入公司名称或代码" name="company.comp_name"></td>
            </tr>
            <tr>
                <td>密&nbsp;&nbsp;&nbsp;码：</td>
                <td><input id="passwords" type="password" placeholder="密码" name="company.comp_pwd"></td>
            </tr>
        </tbody>
        </table>
        
         <input type="button" class="btn btns1" value="登录" onclick="loginCheck()">
         <a class="btn btns2" href="register.jsp" >注册</a>
         <a href="forgetPassword.jsp">
            <span id="forget">忘记密码？</span>
        </a>
        <p class="wait">
            <img src="images/waiting.gif">
            <strong> &nbsp;&nbsp;正在登录...</strong>
        </p>
    </form>
</div>

<script>
	$(function(){
		//发送ajax请求
		$.get("${pageContext.request.contextPath}/category_find",function(data){
			//获取menu的ul标签
			var $ul=$("#menuId");
			//遍历数组
			$(data).each(function(i,n){
				if(i==0){
					$ul.append($("<li><a href='/xjeca'>"+n.cate_name+"</a><i></i></li>"));
				}else if(i==1){
					$ul.append($("<li><a href='/xjeca/aboutus.jsp'>"+n.cate_name+"</a><i></i></li>"));
				}else if(i==6){
					$ul.append($("<li><a href='/xjeca/news_findByPage?categoryId=10'>"+n.cate_name+"</a><i></i></li>"));
				}else if(i==4){
					$ul.append($("<li><a href='company_findByLevel?currPage=1&level=1' >"+n.cate_name+"</a><i></i></li>"));
				}else if(i==5){
					$ul.append($("<li><a href='/xjeca/news_findByPage?categoryId=6' >"+n.cate_name+"</a><i></i></li>"));
				}else if(i==7){
					$ul.append($("<li><a href='contact.jsp'>"+n.cate_name+"</a></li>"));
				}else if(i!=data.length-1){
					$ul.append($("<li><a href=/xjeca/news_findByPage?categoryId="+n.cate_id+">"+n.cate_name+"</a><i></i></li>"));
				}else{
					$ul.append($("<li><a href='#'>"+n.cate_name+"</a></li>"));
				}
				$(' #menuId li').mouseover(function () {
					$(this).addClass("hover").siblings().removeClass("hover");
			    });
			 	$(' #menuId ').mouseout(function () {
			        $(this).children('li').removeClass("hover");
			    });
			});
		},"json");
	});
</script>
<script type="text/javascript">
	function loginCheck(){
		//登录动画开始
		//表单的数据
		var formdata = $("#loginForm").serialize();
		//检测账号状态
		$.post("company_checkLogin?"+formdata,function(data){
			if(data==0){
				//未注册
				$("#usernames").val("");
				$("#usernames").attr("placeholder","账号未注册");
				$("#passwords").val("");
			}else if(data==1){
				//注册未审核
				$("#usernames").val("");
				$("#usernames").attr("placeholder","账号审核中");
				$("#passwords").val("");
			}else if(data==3){
				//账号审核但密码错误
				$("#usernames").val("");
				$("#usernames").attr("placeholder","密码错误");
				$("#passwords").val("");
			}else if(data==2){
				//成功
				//登录动画结束
				$(".wait").show();
				$("#loginForm").submit(); 
				/* $.post("company_login?"+formdata,function(){
					$(".wait").hide();
				}); */
			}
		},"json");
	}
</script>
